<?php

namespace Rjyst\ClickLearn;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Artisan;

class ClickLearnServiceProvider extends ServiceProvider
{
    /**
     * Register services.
     */
    public function register(): void
    {
        //
    }

    /**
     * Bootstrap services.
     */
    public function boot(): void
    {
        // 发布迁移文件
        $this->publishes([
            __DIR__.'/../database/migrations/' => database_path('migrations')
        ], 'click-learn-migrations');

        // 发布 Seeder 文件
        $this->publishes([
            __DIR__.'/../database/seeders/' => database_path('seeders')
        ], 'click-learn-seeders');

        // 发布模型文件
        $this->publishes([
            __DIR__.'/../stubs/Models/' => app_path('Models/Data')
        ], 'click-learn-models');

        // 发布管理后台控制器（保持完整的目录结构）
        $this->publishes([
            __DIR__.'/../stubs/Admin/Controllers/' => app_path('Admin/Controllers')
        ], 'click-learn-controllers');

        // 发布管理后台仓库（保持完整的目录结构）
        $this->publishes([
            __DIR__.'/../stubs/Admin/Repositories/' => app_path('Admin/Repositories')
        ], 'click-learn-repositories');

        // 发布管理后台渲染器（保持完整的目录结构）
        $this->publishes([
            __DIR__.'/../stubs/Admin/Renderable/' => app_path('Admin/Renderable')
        ], 'click-learn-renderable');

        // 注册安装命令
        if ($this->app->runningInConsole()) {
            $this->commands([
                Console\Commands\InstallCommand::class,
            ]);
        }
    }
}
